package com.why.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.why.entity.Communication;
import com.why.service.CommunicationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * (Communication)表控制层
 *
 * @author makejava
 * @since 2023-05-24 21:09:40
 */
@RestController
@RequestMapping("/communication")
public class CommunicationController {
    /**
     * 服务对象
     */
    @Autowired
    private CommunicationService communicationService;

    @PostMapping("/save")
    public String save(@RequestBody Communication communication) {
        communicationService.save(communication);
        return "success";
    }

    @GetMapping("/list")
    public List<Communication> list() {
        LambdaQueryWrapper<Communication> queryWrapper = new LambdaQueryWrapper<Communication>();
        queryWrapper.orderByAsc(Communication::getAddtime);
        List<Communication> communicationList = communicationService.list(queryWrapper);
        System.out.println(communicationList);
        return communicationList;
    }

}

